home *** CD-ROM | disk | FTP | other *** search
/ Champak 138 / Volume 138 Aug 19 2011 - Damaged.iso / Games / shadez.swf / scripts / Local / CMain.as < prev    next >
Encoding:
Text File  |  2011-08-19  |  6.2 KB  |  219 lines

  1. package Local
  2. {
  3.    import Local.Draw.*;
  4.    import Local.External.*;
  5.    import Local.Game.*;
  6.    import Local.Game.World.*;
  7.    import STC9.System.CProfiler;
  8.    import flash.display.*;
  9.    import flash.events.*;
  10.    import flash.geom.*;
  11.    
  12.    public class CMain extends MovieClip
  13.    {
  14.       
  15.       public static var mMinSize:Rectangle = new Rectangle(0,0,700,550);
  16.       
  17.       public static var mMaxSize:Rectangle = new Rectangle(0,0,700,550);
  18.       
  19.       public static var mSize:Rectangle = new Rectangle(0,0,700,550);
  20.        
  21.       
  22.       private var mScreens:CScreen;
  23.       
  24.       public var mcTimer:MovieClip;
  25.       
  26.       public var mProfiler:CProfiler;
  27.       
  28.       private var mGame:CGame;
  29.       
  30.       public function CMain()
  31.       {
  32.          if(true)
  33.          {
  34.             super();
  35.             if(true)
  36.             {
  37.                addEventListener(Event.ADDED_TO_STAGE,Initialize);
  38.             }
  39.             opaqueBackground = 0;
  40.          }
  41.       }
  42.       
  43.       public function UpdateTimer(param1:int) : void
  44.       {
  45.          var _loc2_:String = null;
  46.          var _loc3_:String = null;
  47.          var _loc4_:String = null;
  48.          var _loc5_:String = null;
  49.          if(!CGlobal.mShowVideoTimer)
  50.          {
  51.             return;
  52.          }
  53.          _loc2_ = String(Math.floor(param1 % CGame.SECONDS));
  54.          _loc3_ = String(Math.floor(param1 / CGame.SECONDS) % 60);
  55.          _loc4_ = String(Math.floor(param1 / (CGame.SECONDS * 60)) % 60);
  56.          _loc5_ = String(Math.floor(param1 / (CGame.SECONDS * 60 * 60)) % 24);
  57.          mcTimer.tbTimer.text = p0(_loc5_) + ":" + p0(_loc4_) + ":" + p0(_loc3_) + "." + p0(_loc2_);
  58.       }
  59.       
  60.       private function e_GAME_LOADED(param1:Event = null) : void
  61.       {
  62.          var _loc2_:CScreen_LoadingLevel = null;
  63.          _loc2_ = CScreen_LoadingLevel(param1.currentTarget);
  64.          var _loc3_:*;
  65.          mGame = _loc3_ = _loc2_.mGame;
  66.          addChildAt(_loc3_,0);
  67.          mScreens.Deactivate();
  68.          mGame.addEventListener(CGame.GAME_COMPLETE,e_GAME_COMPLETE);
  69.          mGame.addEventListener(CGame.GAME_EXIT,e_GAME_EXIT);
  70.          mGame.addEventListener(CGame.GAME_DIED,e_GAME_DIED);
  71.          CProfiler.Reset();
  72.          e_RESIZE();
  73.       }
  74.       
  75.       public function Initialize(param1:Event = null) : void
  76.       {
  77.          removeEventListener(Event.ADDED_TO_STAGE,Initialize);
  78.          stage.align = StageAlign.TOP_LEFT;
  79.          stage.scaleMode = StageScaleMode.NO_SCALE;
  80.          addEventListener(Event.ENTER_FRAME,Update);
  81.          stage.addEventListener(Event.RESIZE,e_RESIZE);
  82.          CGlobal.Open();
  83.          mProfiler = new CProfiler("left","fpsonly");
  84.          if(CGlobal.mProfiler)
  85.          {
  86.             addChild(mProfiler);
  87.          }
  88.          mScreens = new CScreen();
  89.          addChildAt(mScreens,0);
  90.          ┬º┬ºpush(mScreens);
  91.          ┬º┬ºpush("main");
  92.          if(true)
  93.          {
  94.             ┬º┬ºpop().AddScreen(┬º┬ºpop(),new Screen_Main());
  95.             mScreens.AddScreen("selectlevel",new Screen_SelectLevel());
  96.             mScreens.AddScreen("loadinglevel",new Screen_LoadingLevel()).addEventListener(CScreen_LoadingLevel.GAME_LOADED,e_GAME_LOADED);
  97.             mScreens.AddScreen("debrief",new Screen_Debrief());
  98.             ┬º┬ºpush(mScreens);
  99.             ┬º┬ºpush("main");
  100.          }
  101.          ┬º┬ºpop().GetScreen(┬º┬ºpop()).Activate();
  102.          mcTimer.visible = CGlobal.mShowVideoTimer;
  103.          CKongregate.Load(this);
  104.          e_RESIZE();
  105.       }
  106.       
  107.       private function e_GAME_DIED(param1:Event = null) : void
  108.       {
  109.          if(true)
  110.          {
  111.             e_GAME_COMPLETE(param1,"died");
  112.          }
  113.       }
  114.       
  115.       private function e_GAME_COMPLETE(param1:Event = null, param2:String = "complete") : void
  116.       {
  117.          if(true)
  118.          {
  119.             CScreen_Debrief.mScore = mGame.mScore;
  120.             if(true)
  121.             {
  122.                CScreen_Debrief.mGameState = param2;
  123.                if(true)
  124.                {
  125.                   mGame.Dispose();
  126.                   if(true)
  127.                   {
  128.                      removeChild(mGame);
  129.                      if(true)
  130.                      {
  131.                         mGame = null;
  132.                         addChildAt(mScreens,0);
  133.                      }
  134.                      CProfiler.Reset();
  135.                   }
  136.                   e_RESIZE();
  137.                }
  138.                UpdateTimer(0);
  139.             }
  140.             mScreens.GetScreen("debrief").Activate();
  141.          }
  142.       }
  143.       
  144.       public function e_RESIZE(param1:Event = null) : void
  145.       {
  146.          if(true)
  147.          {
  148.             ┬º┬ºpush(mGame);
  149.             if(true)
  150.             {
  151.                ┬º┬ºgoto(addr21);
  152.             }
  153.             ┬º┬ºpop().Resize(mSize.width,mSize.height);
  154.          }
  155.          addr21:
  156.          if(┬º┬ºpop())
  157.          {
  158.             ┬º┬ºpush(mGame);
  159.          }
  160.       }
  161.       
  162.       private function p0(param1:String) : String
  163.       {
  164.          ┬º┬ºpush(param1);
  165.          if(true)
  166.          {
  167.             if(┬º┬ºpop().length < 2)
  168.             {
  169.                ┬º┬ºpush("0" + param1);
  170.                if(true)
  171.                {
  172.                }
  173.                ┬º┬ºgoto(addr31);
  174.             }
  175.             else
  176.             {
  177.                ┬º┬ºpush(param1);
  178.             }
  179.             ┬º┬ºpush(┬º┬ºpop());
  180.          }
  181.          addr31:
  182.          return ┬º┬ºpop();
  183.       }
  184.       
  185.       public function Update(param1:Event = null) : void
  186.       {
  187.          CProfiler.StopProfile("_frame.Update");
  188.          mProfiler.Update(true);
  189.          CProfiler.StartProfile("_frame.Update");
  190.          ┬º┬ºpush(mGame);
  191.          if(true)
  192.          {
  193.             if(┬º┬ºpop())
  194.             {
  195.                addr30:
  196.                mGame.Update();
  197.             }
  198.             ┬º┬ºpush(mScreens);
  199.             if(true)
  200.             {
  201.                if(┬º┬ºpop().parent)
  202.                {
  203.                   addr44:
  204.                   mScreens.Process();
  205.                }
  206.                return;
  207.             }
  208.             ┬º┬ºgoto(addr44);
  209.          }
  210.          ┬º┬ºgoto(addr30);
  211.       }
  212.       
  213.       private function e_GAME_EXIT(param1:Event = null) : void
  214.       {
  215.          e_GAME_COMPLETE(param1,"exit");
  216.       }
  217.    }
  218. }
  219.